Optimal. Leaf size=133 \[ \frac {a^2 x}{c^2}+\frac {2 (b c-a d) \left (2 a c^2-b c d-a d^2\right ) \tanh ^{-1}\left (\frac {\sqrt {c-d} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c+d}}\right )}{c^2 (c-d)^{3/2} (c+d)^{3/2} f}+\frac {(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.20, antiderivative size = 133, normalized size of antiderivative = 1.00, number of steps
used = 5, number of rules used = 5, integrand size = 25, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {4026, 2869,
2814, 2738, 214} \begin {gather*} \frac {a^2 x}{c^2}+\frac {(b c-a d)^2 \sin (e+f x)}{c f \left (c^2-d^2\right ) (c \cos (e+f x)+d)}+\frac {2 (b c-a d) \left (2 a c^2-a d^2-b c d\right ) \tanh ^{-1}\left (\frac {\sqrt {c-d} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c+d}}\right )}{c^2 f (c-d)^{3/2} (c+d)^{3/2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 214
Rule 2738
Rule 2814
Rule 2869
Rule 4026
Rubi steps
\begin {align*} \int \frac {(a+b \sec (e+f x))^2}{(c+d \sec (e+f x))^2} \, dx &=\int \frac {(b+a \cos (e+f x))^2}{(d+c \cos (e+f x))^2} \, dx\\ &=\frac {(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}-\frac {\int \frac {-c \left (2 a b c-\left (a^2+b^2\right ) d\right )-a^2 \left (c^2-d^2\right ) \cos (e+f x)}{d+c \cos (e+f x)} \, dx}{c \left (c^2-d^2\right )}\\ &=\frac {a^2 x}{c^2}+\frac {(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}+\frac {\left (c^2 \left (2 a b c-\left (a^2+b^2\right ) d\right )-a^2 d \left (c^2-d^2\right )\right ) \int \frac {1}{d+c \cos (e+f x)} \, dx}{c^2 \left (c^2-d^2\right )}\\ &=\frac {a^2 x}{c^2}+\frac {(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}+\frac {\left (2 \left (c^2 \left (2 a b c-\left (a^2+b^2\right ) d\right )-a^2 d \left (c^2-d^2\right )\right )\right ) \text {Subst}\left (\int \frac {1}{c+d+(-c+d) x^2} \, dx,x,\tan \left (\frac {1}{2} (e+f x)\right )\right )}{c^2 \left (c^2-d^2\right ) f}\\ &=\frac {a^2 x}{c^2}+\frac {2 (b c-a d) \left (2 a c^2-b c d-a d^2\right ) \tanh ^{-1}\left (\frac {\sqrt {c-d} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c+d}}\right )}{c^2 (c-d)^{3/2} (c+d)^{3/2} f}+\frac {(b c-a d)^2 \sin (e+f x)}{c \left (c^2-d^2\right ) f (d+c \cos (e+f x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.73, size = 136, normalized size = 1.02 \begin {gather*} \frac {a^2 (e+f x)+\frac {2 \left (-2 a b c^3+b^2 c^2 d+a^2 \left (2 c^2 d-d^3\right )\right ) \tanh ^{-1}\left (\frac {(-c+d) \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{\left (c^2-d^2\right )^{3/2}}+\frac {c (b c-a d)^2 \sin (e+f x)}{(c-d) (c+d) (d+c \cos (e+f x))}}{c^2 f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.25, size = 195, normalized size = 1.47
method | result | size |
derivativedivides | \(\frac {\frac {-\frac {2 \left (a^{2} d^{2}-2 a b d c +b^{2} c^{2}\right ) c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\left (c^{2}-d^{2}\right ) \left (c \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-d \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-c -d \right )}-\frac {2 \left (2 a^{2} c^{2} d -a^{2} d^{3}-2 a b \,c^{3}+b^{2} c^{2} d \right ) \arctanh \left (\frac {\left (c -d \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\sqrt {\left (c +d \right ) \left (c -d \right )}}\right )}{\left (c +d \right ) \left (c -d \right ) \sqrt {\left (c +d \right ) \left (c -d \right )}}}{c^{2}}+\frac {2 a^{2} \arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{c^{2}}}{f}\) | \(195\) |
default | \(\frac {\frac {-\frac {2 \left (a^{2} d^{2}-2 a b d c +b^{2} c^{2}\right ) c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\left (c^{2}-d^{2}\right ) \left (c \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-d \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-c -d \right )}-\frac {2 \left (2 a^{2} c^{2} d -a^{2} d^{3}-2 a b \,c^{3}+b^{2} c^{2} d \right ) \arctanh \left (\frac {\left (c -d \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\sqrt {\left (c +d \right ) \left (c -d \right )}}\right )}{\left (c +d \right ) \left (c -d \right ) \sqrt {\left (c +d \right ) \left (c -d \right )}}}{c^{2}}+\frac {2 a^{2} \arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{c^{2}}}{f}\) | \(195\) |
risch | \(\frac {a^{2} x}{c^{2}}+\frac {2 i \left (a^{2} d^{2}-2 a b d c +b^{2} c^{2}\right ) \left (d \,{\mathrm e}^{i \left (f x +e \right )}+c \right )}{c^{2} \left (c^{2}-d^{2}\right ) f \left ({\mathrm e}^{2 i \left (f x +e \right )} c +2 d \,{\mathrm e}^{i \left (f x +e \right )}+c \right )}+\frac {2 \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i c^{2}-i d^{2}-\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) a^{2} d}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f}-\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i c^{2}-i d^{2}-\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) a^{2} d^{3}}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f \,c^{2}}-\frac {2 c \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i c^{2}-i d^{2}-\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) a b}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f}+\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i c^{2}-i d^{2}-\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) b^{2} d}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f}-\frac {2 \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c^{2}-i d^{2}+\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) a^{2} d}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f}+\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c^{2}-i d^{2}+\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) a^{2} d^{3}}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f \,c^{2}}+\frac {2 c \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c^{2}-i d^{2}+\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) a b}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f}-\frac {\ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c^{2}-i d^{2}+\sqrt {c^{2}-d^{2}}\, d}{\sqrt {c^{2}-d^{2}}\, c}\right ) b^{2} d}{\sqrt {c^{2}-d^{2}}\, \left (c +d \right ) \left (c -d \right ) f}\) | \(777\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 311 vs.
\(2 (127) = 254\).
time = 2.83, size = 687, normalized size = 5.17 \begin {gather*} \left [\frac {2 \, {\left (a^{2} c^{5} - 2 \, a^{2} c^{3} d^{2} + a^{2} c d^{4}\right )} f x \cos \left (f x + e\right ) + 2 \, {\left (a^{2} c^{4} d - 2 \, a^{2} c^{2} d^{3} + a^{2} d^{5}\right )} f x + {\left (2 \, a b c^{3} d + a^{2} d^{4} - {\left (2 \, a^{2} + b^{2}\right )} c^{2} d^{2} + {\left (2 \, a b c^{4} + a^{2} c d^{3} - {\left (2 \, a^{2} + b^{2}\right )} c^{3} d\right )} \cos \left (f x + e\right )\right )} \sqrt {c^{2} - d^{2}} \log \left (\frac {2 \, c d \cos \left (f x + e\right ) - {\left (c^{2} - 2 \, d^{2}\right )} \cos \left (f x + e\right )^{2} + 2 \, \sqrt {c^{2} - d^{2}} {\left (d \cos \left (f x + e\right ) + c\right )} \sin \left (f x + e\right ) + 2 \, c^{2} - d^{2}}{c^{2} \cos \left (f x + e\right )^{2} + 2 \, c d \cos \left (f x + e\right ) + d^{2}}\right ) + 2 \, {\left (b^{2} c^{5} - 2 \, a b c^{4} d + 2 \, a b c^{2} d^{3} - a^{2} c d^{4} + {\left (a^{2} - b^{2}\right )} c^{3} d^{2}\right )} \sin \left (f x + e\right )}{2 \, {\left ({\left (c^{7} - 2 \, c^{5} d^{2} + c^{3} d^{4}\right )} f \cos \left (f x + e\right ) + {\left (c^{6} d - 2 \, c^{4} d^{3} + c^{2} d^{5}\right )} f\right )}}, \frac {{\left (a^{2} c^{5} - 2 \, a^{2} c^{3} d^{2} + a^{2} c d^{4}\right )} f x \cos \left (f x + e\right ) + {\left (a^{2} c^{4} d - 2 \, a^{2} c^{2} d^{3} + a^{2} d^{5}\right )} f x + {\left (2 \, a b c^{3} d + a^{2} d^{4} - {\left (2 \, a^{2} + b^{2}\right )} c^{2} d^{2} + {\left (2 \, a b c^{4} + a^{2} c d^{3} - {\left (2 \, a^{2} + b^{2}\right )} c^{3} d\right )} \cos \left (f x + e\right )\right )} \sqrt {-c^{2} + d^{2}} \arctan \left (-\frac {\sqrt {-c^{2} + d^{2}} {\left (d \cos \left (f x + e\right ) + c\right )}}{{\left (c^{2} - d^{2}\right )} \sin \left (f x + e\right )}\right ) + {\left (b^{2} c^{5} - 2 \, a b c^{4} d + 2 \, a b c^{2} d^{3} - a^{2} c d^{4} + {\left (a^{2} - b^{2}\right )} c^{3} d^{2}\right )} \sin \left (f x + e\right )}{{\left (c^{7} - 2 \, c^{5} d^{2} + c^{3} d^{4}\right )} f \cos \left (f x + e\right ) + {\left (c^{6} d - 2 \, c^{4} d^{3} + c^{2} d^{5}\right )} f}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\left (a + b \sec {\left (e + f x \right )}\right )^{2}}{\left (c + d \sec {\left (e + f x \right )}\right )^{2}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.57, size = 237, normalized size = 1.78 \begin {gather*} \frac {\frac {{\left (f x + e\right )} a^{2}}{c^{2}} + \frac {2 \, {\left (2 \, a b c^{3} - 2 \, a^{2} c^{2} d - b^{2} c^{2} d + a^{2} d^{3}\right )} {\left (\pi \left \lfloor \frac {f x + e}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, c + 2 \, d\right ) + \arctan \left (-\frac {c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}{\sqrt {-c^{2} + d^{2}}}\right )\right )}}{{\left (c^{4} - c^{2} d^{2}\right )} \sqrt {-c^{2} + d^{2}}} - \frac {2 \, {\left (b^{2} c^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 2 \, a b c d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + a^{2} d^{2} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )\right )}}{{\left (c^{3} - c d^{2}\right )} {\left (c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - c - d\right )}}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 10.20, size = 2500, normalized size = 18.80 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________